Skip to content

Conversation

@aalavandhan
Copy link
Member

@aalavandhan aalavandhan commented Jan 31, 2026

Implement a vault that holds underlying (AMPL) and perp (SPOT) tokens and auto-rebalances to maintain the system's target deviation ratio via IRolloverVault swaps.

Key features:

  • Deposit underlying tokens and mint vault notes (LP tokens)
  • Redeem notes for proportional underlying + perp tokens
  • Auto-rebalance when system DR is outside equilibrium zone:
    • DR < 1 (perpTVL too high): redeem perps to decrease perpTVL
    • DR > 1 (perpTVL too low): mint perps to increase perpTVL
  • Rebalance formula: requiredChange = perpTVL × |dr - targetDR|
    (rolloverVaultTVL unchanged during flash mint/redeem)
  • Liquidity limits based on swap direction:
    • underlying->perp: limited by underlying balance
    • perp->underlying: limited by perp value held
  • Separate lag factors and percentage limits for each direction
  • Slippage protection with configurable max swap fee percentage
  • Keeper-controlled pause functionality.

@openzeppelin-code
Copy link

openzeppelin-code bot commented Jan 31, 2026

DRBalancerVault contract for system DR rebalancing

Generated at commit: b5bcd537fb3940a962c572a700e915ad97021550

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
1
0
0
3
24
28
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@aalavandhan aalavandhan force-pushed the dr-balancer-vault branch 10 times, most recently from 404525b to ecdf37e Compare January 31, 2026 20:55
… and auto-rebalances to maintain the system's target deviation ratio via IRolloverVault swaps.

Key features:
- Deposit underlying tokens and mint vault notes (LP tokens)
- Redeem notes for proportional underlying + perp tokens
- Auto-rebalance when system DR is outside equilibrium zone:
    DR < 1 (perpTVL too high): redeem perps to decrease perpTVL
    DR > 1 (perpTVL too low): mint perps to increase perpTVL
- Rebalance formula: requiredChange = perpTVL × |dr - targetDR|
  (rolloverVaultTVL unchanged during flash mint/redeem)
- Liquidity limits based on swap direction:
    underlying->perp: limited by underlying balance
    perp->underlying: limited by perp value held
- Separate lag factors and percentage limits for each direction
- Slippage protection with configurable max swap fee percentage
- Keeper-controlled pause functionality.
…page protection

- Update deposit() to accept both underlying and perp tokens with signature:
  deposit(underlyingAmtMax, perpAmtMax, minNotesMinted)
- Update redeem() to include slippage protection with signature:
  redeem(notesAmt, minUnderlyingAmtOut, minPerpAmtOut)
- Update computeMintAmt() to return (notesMinted, underlyingAmtIn, perpAmtIn)
- First deposit accepts any ratio; subsequent deposits enforce vault ratio
- Update Deposited event to include perpAmtIn
- Fix lag factor comments (swapped DR conditions)
- Add InvalidLagFactor validation to prevent division by zero
- Update contract docstring to reflect dual-token deposits

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Range memory equilibriumDR_
) external onlyOwner {
if (
equilibriumDR_.lower >= equilibriumDR_.upper ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be able to configure a range of size zero and allow it to be just the target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants